#ifndef LINUXFFMPEGPROJECT_UTILS_TIMER_H
#define LINUXFFMPEGPROJECT_UTILS_TIMER_H

#include <memory>
#include <functional>

typedef enum _TimerMode {
    kBlockingTimer    = 0,
    kNonBlockingTimer = 1
}TimerMode;

typedef enum _TimerStopMode {
    kCallingFunc        = 0,
    kWithOutCallingFunc = 1
}TimerStopMode;

#ifndef INFINITE_LOOP
#define INFINITE_LOOP 0
#endif

class WorkTimer {
public:
    WorkTimer();
    ~WorkTimer();
public:
    // 单位毫秒
    void setDelayTime(const int dt);
    /**
    * @brief when rp_times is equal to zero, mean infinite loop
    *
    * @author zzk
    * @date 2022-07-25 19:39:11
    * @version
    * @param rp_times
    *
    */
    void setRepeatTimes(const int rp_times = 1);
    void addCallbackFunc(const std::function<void()> &func);
    void clearCallbackList();

    void startTimer(const TimerMode mode = kNonBlockingTimer);
    void stopTimer(const TimerStopMode mode = kWithOutCallingFunc);


private:
    class WorkTimerImpl;
    std::unique_ptr<WorkTimerImpl> p_impl_;
};

#endif